﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XYZshell.Game.CardGameEngine
{
	public abstract class FlowActivity : BaseActivity, IFlow
	{
		public FlowActivity()
			: base()
		{
		}

		public abstract override  void Start();
		protected override void OnFinished( EventArgs e )
		{
			base.OnFinished( e );
			if (Next != null)
				Next.Start();
		}

		#region IFlow 成员
		IActivity _prev;
		public IActivity Previous
		{
			get
			{
				return _prev;
			}
			set
			{
				_prev = value;
				this.Variables = value.Variables;
				if (value is IFlow)
				{
					IFlow f=(IFlow)value;
					if (f.Next != this)
					{
						f.Next = this;
					}
				}
			}
		}
		IActivity _next;
		public IActivity Next
		{
			get{
				return _next;
			}
			set
			{
				_next = value;
				value.Variables = this.Variables;

				if (value is IFlow)
				{
					IFlow f=(IFlow)value ;
					if (f.Previous != this)
					{
						f.Previous = this;
					}
				}
			}
		}

		#endregion
	}
	public class FlowEventArgs : EventArgs
	{
		public IActivity Next
		{
			get;
			set;
		}
		public IActivity Previous
		{
			get;
			set;
		}
	}
}
